package Day13_StringBuilder类;

//统计字符串中大小写字母数字各多少个?

import java.util.Scanner;

public class String_统计字符串 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("输入一个字符串:");
        String s = sc.next();

        //计数器思想
        //定义3个变量 保存大写字母数量, 小写字母数量, 数字数量
        int countA = 0;
        int counta = 0;
        int count1 = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {          // >=65  <=90
                countA++;
            } else if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z') {   // >=97  <=122
                counta++;
            } else if (s.charAt(i) >= '0' && s.charAt(i) <= '9') {   // >=48  <=57
                count1++;
            }
        }
        System.out.println("大写字母数量:" + countA);
        System.out.println("小写字母数量:" + counta);
        System.out.println("数字字符数量:" + count1);

    }
}
